library(dplyr)
library(ggplot2)
library(interflex)
library(wesanderson)
library(car)
library(knitr)
polyp_data<-read.csv("RecruitsByFilter.csv",header = T)
realdata<-read.csv(file="IsotopesByFilter.csv",header = T)
realdata$Filter<-as.character(realdata$Filter)
SpT<-cor.test(polyp_data$NumTotal,polyp_data$PercentB, method="spearman",exact=FALSE)
SpT
##
## Spearman's rank correlation rho
##
## data: polyp_data$NumTotal and polyp_data$PercentB
## S = 33234011, p-value = 0.8266
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## 0.009071257
| Filter | avgTotal | avgB | minTotal | minB | maxTotal | maxB |
|---|---|---|---|---|---|---|
| 101 | 487224.5 | 1.0000000 | 92165.5 | 1.0000000 | 1222620.0 | 1.0000000 |
| 105 | 745045.8 | 0.9986744 | 157997.0 | 0.9880699 | 1516039.0 | 1.0000000 |
| 106 | 994115.5 | 0.9901316 | 704630.5 | 0.9838100 | 1904399.0 | 0.9971492 |
| 107 | 1077985.3 | 0.9769939 | 508046.0 | 0.9723363 | 1712819.5 | 0.9836851 |
| 109 | 701177.4 | 0.9484360 | 179028.5 | 0.9416801 | 1528243.5 | 0.9563802 |
| 110 | 677881.8 | 0.9143466 | 116889.5 | 0.8821341 | 1770324.5 | 0.9416457 |
| 111 | 538037.5 | 0.8679713 | 143825.5 | 0.8479790 | 1175128.5 | 0.8795435 |
| 112 | 567355.9 | 0.8215042 | 75103.0 | 0.8029045 | 1164044.0 | 0.8381623 |
| 113 | 298929.0 | 0.7374998 | 83944.0 | 0.6979079 | 595896.0 | 0.7856916 |
| 114 | 417237.7 | 0.5673313 | 58180.5 | 0.5438711 | 1490926.5 | 0.5986435 |
| 115 | 268738.8 | 0.4945384 | 117092.5 | 0.4635342 | 494116.0 | 0.5277840 |
| 116 | 851287.5 | 0.4223467 | 95949.0 | 0.4011089 | 2036947.5 | 0.4484514 |
| 117 | 439236.0 | 0.3831510 | 58383.5 | 0.3771028 | 1182860.0 | 0.3967924 |
| 118 | 755547.8 | 0.3462678 | 56423.5 | 0.3191870 | 1632288.0 | 0.3685297 |
| 119 | 804276.7 | 0.2981005 | 352247.0 | 0.2843354 | 1858412.5 | 0.3121944 |
| 120 | 668280.6 | 0.2659583 | 233198.0 | 0.2569290 | 1051529.5 | 0.2779034 |
| 121 | 712029.5 | 0.2347079 | 229376.0 | 0.2229417 | 1616965.0 | 0.2533138 |
| 122 | 528216.5 | 0.2039470 | 200879.0 | 0.1854782 | 788245.5 | 0.2200231 |
| 123 | 528653.7 | 0.1726026 | 315518.0 | 0.1661478 | 796103.0 | 0.1809802 |
| 124 | 752131.1 | 0.1601849 | 290538.5 | 0.1527942 | 1294198.5 | 0.1660982 |
| 125 | 771905.1 | 0.1481103 | 262741.5 | 0.1399914 | 1529563.0 | 0.1524782 |
| 126 | 773595.6 | 0.1344502 | 265891.5 | 0.1294345 | 1552390.0 | 0.1390628 |
| 127 | 852532.8 | 0.1195182 | 330407.0 | 0.1143290 | 2227235.5 | 0.1275739 |
| 128 | 1020178.2 | 0.1071333 | 401170.0 | 0.1013785 | 1740970.0 | 0.1136545 |
| 129 | 894086.9 | 0.0899172 | 487476.5 | 0.0844588 | 1339292.5 | 0.0962398 |
| 130 | 851089.1 | 0.0791006 | 532322.0 | 0.0750516 | 1391533.5 | 0.0843178 |
| 131 | 1023938.7 | 0.0658829 | 296257.5 | 0.0608532 | 1747147.5 | 0.0728520 |
| 132 | 776287.4 | 0.0560944 | 347214.0 | 0.0501511 | 1071973.0 | 0.0592773 |
| 133 | 1015835.8 | 0.0450492 | 243859.0 | 0.0425270 | 1588195.0 | 0.0488792 |
| 134 | 1047744.9 | 0.0375665 | 482989.5 | 0.0312645 | 1729549.5 | 0.0423864 |
| 135 | 934440.5 | 0.0264688 | 95791.5 | 0.0212649 | 1597494.5 | 0.0308356 |
| 136 | 886615.1 | 0.0157772 | 443345.0 | 0.0121576 | 1243228.0 | 0.0200135 |
| 137 | 924399.0 | 0.0087392 | 336542.5 | 0.0054598 | 1753832.5 | 0.0117583 |
| 138 | 1172438.8 | 0.0031178 | 477368.5 | 0.0011359 | 2209858.0 | 0.0052659 |
| 139 | 723727.7 | 0.0000000 | 459567.5 | 0.0000000 | 1311611.0 | 0.0000000 |
| 141 | 351451.8 | 0.0000000 | 102000.5 | 0.0000000 | 1120392.0 | 0.0000000 |
| 143 | 771572.6 | 0.0000000 | 215859.0 | 0.0000000 | 1687294.0 | 0.0000000 |
| 144 | 490419.3 | 0.0000000 | 76195.0 | 0.0000000 | 1137185.0 | 0.0000000 |
| 145 | 839800.5 | 0.0000000 | 302904.0 | 0.0000000 | 1665926.5 | 0.0000000 |
| 146 | 764848.3 | 0.0000000 | 421809.5 | 0.0000000 | 1483902.0 | 0.0000000 |
| 147 | 443710.8 | 0.0000000 | 239568.0 | 0.0000000 | 728672.0 | 0.0000000 |
| 148 | 470368.2 | 0.0000000 | 197141.0 | 0.0000000 | 637689.5 | 0.0000000 |
| 149 | 495601.0 | 0.0000000 | 143643.5 | 0.0000000 | 991280.5 | 0.0000000 |
| 151 | 592994.5 | 0.0000000 | 224616.0 | 0.0000000 | 1324708.0 | 0.0000000 |
| 156 | 580757.1 | 0.0000000 | 296912.0 | 0.0000000 | 919621.5 | 0.0000000 |
| 158 | 581435.1 | 0.0000000 | 235147.5 | 0.0000000 | 944510.0 | 0.0000000 |
| 160 | 972407.4 | 0.0000000 | 141067.5 | 0.0000000 | 1681603.0 | 0.0000000 |
ggplot(byfilter)+
geom_pointrange(aes(x=Filter,y=avgTotal,ymin=minTotal,ymax=maxTotal,color=avgB))+
theme_bw()+
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black"),
axis.text.x=element_blank())+
scale_color_gradientn(colours=rev(wes_palette("Zissou1")),name="Symbiont Ratio (%B.m.)")+
scale_y_continuous(labels = scales::comma)+
xlab("Filter")+
ylab("Symbiont density (cells/recruit)")
ggplot(byfilter)+
geom_pointrange(aes(x=Filter,y=avgB,ymin=minB,ymax=maxB,color=avgTotal))+
theme_bw()+
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black"),
axis.text.x=element_blank())+
scale_color_gradientn(colours=c("#D8B70A", "#02401B"), labels = scales::comma,name="Symbiont density")+
scale_y_continuous(labels = scales::comma)+
xlab("Filter")+
ylab("Symbiont Ratio (Prop of B.m.)")
lmHostAPC<-lm(HostAP_C~PercentB+CellsPerPolyp,data=realdata)
summary(lmHostAPC)
##
## Call:
## lm(formula = HostAP_C ~ PercentB + CellsPerPolyp, data = realdata)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.04147 -0.01043 0.00030 0.01252 0.03573
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.188e+00 9.022e-03 131.660 < 2e-16 ***
## PercentB 5.429e-04 7.486e-05 7.252 4.31e-09 ***
## CellsPerPolyp 2.697e-08 1.128e-08 2.391 0.0211 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.01848 on 45 degrees of freedom
## Multiple R-squared: 0.5598, Adjusted R-squared: 0.5403
## F-statistic: 28.61 on 2 and 45 DF, p-value: 9.59e-09
res<-resid(lmHostAPC)
qqnorm(res)
qqline(res)
layout(matrix(c(1,2,3,4),2,2)) # optional 4 graphs/page
plot(lmHostAPC)
ggplot(realdata,aes(x=PercentB,y=HostAP_C,color=CellsPerPolyp))+
geom_point(size=2.5)+
theme_bw()+
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black"))+
geom_smooth(method="lm", colour="black", se = F)+
scale_color_gradientn(colours=c("#D8B70A", "#02401B"), labels = scales::comma,name="Symbiont density")+
xlab("Symbiont Ratio (Percent B.m.)")+
ylab("AP 13C in Host Tissue")
ggplot(realdata,aes(x=CellsPerPolyp,y=HostAP_C,color=PercentB))+
geom_point(size=2.5)+
theme_bw()+
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black"))+
coord_cartesian(clip = "off") +
geom_smooth(method="lm", colour="black", se = F)+
scale_color_gradientn(colours=rev(wes_palette("Zissou1")),name="Symbiont Ratio (% B.m.)")+
scale_x_continuous(labels = scales::comma)+
xlab("Symbiont density (cells/recruit)")+
ylab("AP 13C in Host Tissue")
lmSymAPC<-lm(SymAP_C~PercentB*CellsPerPolyp,data=realdata)
summary(lmSymAPC)
##
## Call:
## lm(formula = SymAP_C ~ PercentB * CellsPerPolyp, data = realdata)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.057488 -0.024180 -0.007259 0.020156 0.115629
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.292e+00 2.375e-02 54.390 <2e-16 ***
## PercentB -4.821e-04 4.291e-04 -1.124 0.2673
## CellsPerPolyp -4.430e-08 3.033e-08 -1.460 0.1513
## PercentB:CellsPerPolyp 1.141e-09 5.254e-10 2.172 0.0353 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03464 on 44 degrees of freedom
## Multiple R-squared: 0.2252, Adjusted R-squared: 0.1724
## F-statistic: 4.263 on 3 and 44 DF, p-value: 0.009976
res<-resid(lmSymAPC)
qqnorm(res)
qqline(res)
layout(matrix(c(1,2,3,4),2,2)) # optional 4 graphs/page
plot(lmSymAPC)
##examine the effects of outlier removal
realdata1<-filter(realdata,Filter!="145")
realdata1<-filter(realdata1,Filter!="144")
lmSymAPC1<-lm(SymAP_C~PercentB*CellsPerPolyp,data=realdata1)
summary(lmSymAPC1)
##
## Call:
## lm(formula = SymAP_C ~ PercentB * CellsPerPolyp, data = realdata1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.051763 -0.015627 -0.003833 0.019258 0.060035
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.273e+00 1.826e-02 69.711 <2e-16 ***
## PercentB -2.103e-04 3.243e-04 -0.649 0.520
## CellsPerPolyp -2.985e-08 2.312e-08 -1.291 0.204
## PercentB:CellsPerPolyp 9.327e-10 3.951e-10 2.361 0.023 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.02561 on 42 degrees of freedom
## Multiple R-squared: 0.4132, Adjusted R-squared: 0.3713
## F-statistic: 9.858 on 3 and 42 DF, p-value: 4.8e-05
interflex(estimator = "linear",data = realdata , Y = "SymAP_C", D = "PercentB", X= "CellsPerPolyp",xlab = "Moderator: Symbiont density (cells/recruit)",ylab = "Marginal Effect of Symbiont Ratio on AP13Csym",theme.bw = TRUE,show.grid = FALSE,cex.axis = 0.7, cex.lab=0.7)
#subset data according to marginal effects plots to visualize trends
More7<-filter(realdata,CellsPerPolyp>=700000)
notMore7<-filter(realdata,CellsPerPolyp<700000)
ggplot(More7,aes(x=PercentB,y=SymAP_C,color=CellsPerPolyp))+
geom_point(size=2.5)+
theme_bw()+
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black"),
axis.text.x=element_blank())+
geom_smooth(method="lm", colour="black", se = F)+
geom_point(data=notMore7,size=2.5,shape=17)+
geom_smooth(data=notMore7,method="lm",color="gray",linetype="dashed", se =F)+
scale_color_gradientn(colours=c("#D8B70A", "#02401B"),name="Symbiont density")+
xlab("Percent B.m.")+
ylab("AP 13C in Symbiont Tissues")
ggplot(realdata,aes(x=CellsPerPolyp,y=SymAP_C,color=PercentB))+
geom_point(size=2.5)+
theme_bw()+
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black"))+
scale_color_gradientn(colours=rev(wes_palette("Zissou1")),name="Symbiont Ratio (% B.m.)")+
scale_x_continuous(labels = scales::comma)+
xlab("Symbiont density (cells/recruit)")+
ylab("AP 13C in Symbiont Tissue")
lmHostAPN<-lm(HostAP_N~PercentB*CellsPerPolyp,data=realdata)
summary(lmHostAPN)
##
## Call:
## lm(formula = HostAP_N ~ PercentB * CellsPerPolyp, data = realdata)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.022750 -0.009800 -0.000628 0.009734 0.046457
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.338e-01 1.007e-02 43.099 < 2e-16 ***
## PercentB -3.591e-04 1.804e-04 -1.991 0.05290 .
## CellsPerPolyp -4.005e-08 1.284e-08 -3.119 0.00324 **
## PercentB:CellsPerPolyp 4.609e-10 2.204e-10 2.091 0.04249 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.0145 on 43 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.1846, Adjusted R-squared: 0.1278
## F-statistic: 3.246 on 3 and 43 DF, p-value: 0.03097
res<-resid(lmHostAPN)
qqnorm(res)
qqline(res)
layout(matrix(c(1,2,3,4),2,2)) # optional 4 graphs/page
plot(lmHostAPN)
interflex(estimator = "linear",data = realdata , Y = "HostAP_N", X = "PercentB", D= "CellsPerPolyp",treat.type = "continuous",nbins=7,xlab = "Moderator: Symbiont Ratio",ylab = "Marginal Effect of Sym Density on AP15Nhost",na.rm=T,theme.bw = TRUE,show.grid = FALSE,cex.axis = 0.7, cex.lab=0.7)
less_B50<-filter(realdata,PercentB<=50)
more_B50<-filter(realdata,PercentB>50)
ggplot(realdata,aes(x=PercentB,y=HostAP_N,color=CellsPerPolyp))+
geom_point(size=2.5)+
theme_bw()+
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black"))+
scale_color_gradientn(colours=c("#D8B70A", "#02401B"), labels = scales::comma,name="Symbiont density")+
xlab("Symbiont Ratio (Percent B.m.)")+
ylab("AP 15N in Host Tissue")
ggplot(less_B50,aes(x=CellsPerPolyp,y=HostAP_N,color=PercentB))+
geom_point(size=2.5)+
theme_bw()+
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black"))+
geom_smooth(method="lm", se = F,color="black")+
geom_point(data=more_B50,shape=17,size=2.5)+
geom_smooth(data=more_B50, method = "lm", se = F, color="gray",linetype="dashed")+
scale_color_gradientn(colours=rev(wes_palette("Zissou1")),name="Symbiont Ratio (% B.m.)")+
scale_x_continuous(labels = scales::comma)+
scale_y_continuous(limits=c(0.375,0.475))+
xlab("Symbiont density (cells/recruit)")+
ylab("AP 15N in Host Tissues")
lmSymAPN<-lm(SymAP_N~PercentB*CellsPerPolyp,data=realdata)
summary(lmSymAPN)
##
## Call:
## lm(formula = SymAP_N ~ PercentB * CellsPerPolyp, data = realdata)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.03275 -0.01093 -0.00181 0.00742 0.06651
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.647e-01 1.300e-02 35.757 < 2e-16 ***
## PercentB -9.569e-04 2.348e-04 -4.075 0.000189 ***
## CellsPerPolyp -6.692e-08 1.660e-08 -4.032 0.000216 ***
## PercentB:CellsPerPolyp 9.536e-10 2.875e-10 3.317 0.001831 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.01896 on 44 degrees of freedom
## Multiple R-squared: 0.3574, Adjusted R-squared: 0.3136
## F-statistic: 8.158 on 3 and 44 DF, p-value: 0.0001987
res<-resid(lmSymAPN)
qqnorm(res)
qqline(res)
layout(matrix(c(1,2,3,4),2,2)) # optional 4 graphs/page
plot(lmSymAPN)
interflex(estimator = "linear",data = realdata , Y = "SymAP_N", X = "PercentB", D= "CellsPerPolyp",treat.type = "continuous",xlab = "Moderator: Symbiont Ratio",ylab = "Marginal Effect of Sym Density on AP15Nsym",na.rm=T,theme.bw = TRUE,show.grid = FALSE,cex.axis = 0.7, cex.lab=0.7,nbins=7)
interflex(estimator = "linear",data = realdata , Y = "SymAP_N", D = "PercentB", X= "CellsPerPolyp",treat.type = "continuous",nbins=7,xlab = "Moderator: Symbiont Density",ylab = "Marginal Effect of Sym Ratio on AP15Nsym",na.rm=T,theme.bw = TRUE,show.grid = FALSE,cex.axis = 0.7, cex.lab=0.7)
#subset data according to marginal effects plots to visualize trends
More8<-filter(realdata,CellsPerPolyp>=800000)
notMore8<-filter(realdata,CellsPerPolyp<800000)
ggplot(notMore8,aes(x=PercentB,y=SymAP_N,color=CellsPerPolyp))+
geom_point(size=2.5)+
theme_bw()+
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black"),
axis.text.x=element_blank())+
geom_smooth(method="lm", colour="black", se = F)+
geom_point(data=More8,size=2.5,shape=17)+
geom_smooth(data=More8,method="lm",color="gray",linetype="dashed", se =F)+
scale_color_gradientn(colours=c("#D8B70A", "#02401B"),name="Symbiont density")+
xlab("Percent B.m.")+
ylab("AP 15N in Symbiont Tissues")
ggplot(less_B50,aes(x=CellsPerPolyp,y=SymAP_N,color=PercentB))+
geom_point(size=2.5)+
theme_bw()+
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black"))+
geom_smooth(method="lm", se = F,color="black")+
geom_point(data=more_B50,shape=17,size=2.5)+
geom_smooth(data=more_B50, method = "lm", se = F, color="gray",linetype="dashed")+
scale_color_gradientn(colours=rev(wes_palette("Zissou1")),name="Symbiont Ratio (% B.m.)")+
scale_x_continuous(labels = scales::comma)+
xlab("Symbiont density (cells/recruit)")+
ylab("AP 15N in Symbiont Tissues")
ggplot(more_B50,aes(x=SymAP_N,y=HostAP_N,color=PercentB))+
geom_point(size=2.5)+
theme_bw()+
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black"))+
geom_smooth(method="glm", colour="#3b9ab2", se = F, method.args = list(family="gaussian"))+
geom_point(data=less_B50,shape=17,size=2.5)+
geom_smooth(data=less_B50,method="glm", colour="#F21A00", se = F, method.args = list(family="gaussian"))+
geom_abline(slope=1,intercept=0,colour="gray",linetype="dashed")+
scale_color_gradientn(colours=rev(wes_palette("Zissou1")),name=element_blank())+
xlab("AP 15N in Sym Tissue")+
ylab("AP 15N in Host Tissue")
lmNewN<-lm(CombNewNPolyp~PercentB*CellsPerPolyp,data=realdata)
summary(lmNewN)
##
## Call:
## lm(formula = CombNewNPolyp ~ PercentB * CellsPerPolyp, data = realdata)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.0114658 -0.0048160 -0.0000326 0.0029751 0.0198387
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.707e-02 4.528e-03 5.977 3.95e-07 ***
## PercentB -1.730e-04 8.116e-05 -2.131 0.03883 *
## CellsPerPolyp -1.884e-08 5.777e-09 -3.262 0.00217 **
## PercentB:CellsPerPolyp 2.388e-10 9.918e-11 2.408 0.02041 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.006521 on 43 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.202, Adjusted R-squared: 0.1464
## F-statistic: 3.629 on 3 and 43 DF, p-value: 0.02021
res<-resid(lmNewN)
qqnorm(res)
qqline(res)
layout(matrix(c(1,2,3,4),2,2)) # optional 4 graphs/page
plot(lmNewN)
##examine the effects of outlier removal
realdata1<-filter(realdata,Filter!="145")
realdata1<-filter(realdata1,Filter!="144")
lmNewN1<-lm(CombNewNPolyp~PercentB*CellsPerPolyp,data=realdata1)
summary(lmNewN1)
##
## Call:
## lm(formula = CombNewNPolyp ~ PercentB * CellsPerPolyp, data = realdata1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.0093720 -0.0040182 0.0003198 0.0034878 0.0114762
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.427e-02 3.872e-03 6.267 1.8e-07 ***
## PercentB -1.342e-04 6.808e-05 -1.971 0.05550 .
## CellsPerPolyp -1.684e-08 4.898e-09 -3.438 0.00136 **
## PercentB:CellsPerPolyp 2.111e-10 8.281e-11 2.549 0.01462 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.005356 on 41 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.2522, Adjusted R-squared: 0.1975
## F-statistic: 4.609 on 3 and 41 DF, p-value: 0.007199
res<-resid(lmNewN1)
qqnorm(res)
qqline(res)
layout(matrix(c(1,2,3,4),2,2)) # optional 4 graphs/page
plot(lmNewN1)
interflex(estimator = "linear",data = realdata , Y = "CombNewNPolyp", X = "PercentB", D= "CellsPerPolyp",treat.type = "continuous",xlab = "Moderator: Symbiont Ratio",ylab = "Marginal Effect of Sym Density on Total New N",na.rm=T,theme.bw = TRUE,show.grid = FALSE,cex.axis = 0.7, cex.lab=0.7,nbins=7)
ggplot(less_B50,aes(x=CellsPerPolyp,y=CombNewNPolyp,color=PercentB))+
geom_point(size=2.5)+
theme_bw()+
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black"))+
geom_smooth(method="lm", se = F,color="black")+
geom_point(data=more_B50,shape=17,size=2.5)+
geom_smooth(data=more_B50, method = "lm", se = F, color="gray",linetype="dashed")+
scale_color_gradientn(colours=rev(wes_palette("Zissou1")),name="Symbiont Ratio (% B.m.)")+
scale_x_continuous(labels = scales::comma)+
xlab("Symbiont density (cells/recruit)")+
ylab("Total Assimilated N (mg)/recruit")